import React from "react";
import { Link, useRoutes } from "react-router-dom";
// import Home from "./pages/Home";
// import About from "./pages/About";

// const Home = lazy(() => import("./pages/Home"));
// const About = lazy(() => import("./pages/About"));

// const Hot = lazy(() => import("./pages/Hot"));
// const Wait = lazy(() => import("./pages/Wait"));

// const LazyLoad = (props) => {
//   return <Suspense fallback={<div>loading...</div>}>{props.comp}</Suspense>;
// };

import routes from "./router";

const App = () => {
  const element = useRoutes(routes);

  return (
    <>
      <h2>路由懒加载</h2>
      <ul>
        <li>
          <Link to="/home">首页</Link>
        </li>
        <li>
          <Link to="/about">关于页</Link>
        </li>
      </ul>

      <hr />

      {element}

      {/* <Routes>
        <Route path="/home" element={<LazyLoad comp={<Home />}></LazyLoad>}>
          <Route
            path="hot"
            element={<LazyLoad comp={<Hot />}></LazyLoad>}
          ></Route>
          <Route
            path="wait"
            element={<LazyLoad comp={<Wait />}></LazyLoad>}
          ></Route>
        </Route>
        <Route
          path="/about"
          element={<LazyLoad comp={<About />}></LazyLoad>}
        ></Route>
      </Routes> */}
    </>
  );
};

export default App;
